/* indent size: 2 */

module.exports = app => {
  const DataTypes = app.Sequelize;

  const Model = app.model.define('visit_records', {
    dorm_visit_id: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      primaryKey: true,
      autoIncrement:true
    },
    dorm_id: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      references: {
        model: 'info_dorm',
        key: 'dormitory_id'
      }
    },
    visit_name: {
      type: DataTypes.STRING(50),
      allowNull: false
    },
    visit_companion: {
      type: DataTypes.STRING(200),
      allowNull: false
    },
    phone: {
      type: DataTypes.STRING(12),
      allowNull: false
    },
    visit_time: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: DataTypes.literal('CURRENT_TIMESTAMP')
    },
    visit_remark: {
      type: DataTypes.STRING(500),
      allowNull: false
    },
    room_id: {
      type: DataTypes.INTEGER(10),
      allowNull: false
    },
    leave_time: {
      type: DataTypes.DATE,
      allowNull: true
    }
  }, {
    tableName: 'visit_records'
  });

  Model.associate = function() {

  }

  return Model;
};
